package com.yang.cloud.feign;

import com.yang.cloud.entity.User;
import com.yang.cloud.hystric.UserFeignClientHystrix;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @author yang.yang@karakal.com.cn
 * @version V1.0
 * @Description:
 * @date 2017-11-13 17:59
 */
@FeignClient(value = "service-provider-user",fallback = UserFeignClientHystrix.class)//默认使用的是springmvc契约，所以可以使用springmvc的注解
public interface UserFeignClient {

    @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
    public User findById(@PathVariable("id") Long id); // 两个坑：1. @GetMapping不支持   2. @PathVariable得设置value

    @RequestMapping(value = "/user", method = RequestMethod.POST)
    public User postUser(@RequestBody User user);

    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public List<User> getUser();

    @RequestMapping(value = "/eureka-instance", method = RequestMethod.GET)
    public String eurekaInstance();

    @RequestMapping(value = "/instance-info", method = RequestMethod.GET)
    public ServiceInstance instanceInfo();
}
